import wx
import wx.combo
import wx.lib.colourselect as  csel
import xmlrpclib
import wx.lib.ogl as ogl
import wx.aui

DHSProxy=xmlrpclib.ServerProxy("http://localhost:62752")
SkypeProxy = xmlrpclib.ServerProxy('http://localhost:62750')

class settings():
    def __init__(self,Ulist,Cfglist):
        self.Ulist=Ulist
        self.Cfglist=Cfglist
        
class GUISetup(wx.Frame):
    def __init__(self,title,parent=None,id=-1,size=(500,300)):
        wx.Frame.__init__(self,parent,id,title,size)
        self.CList=self.GetClist() #get conference list
        self.MList=["a"]
        print "Conference List:"+str(self.CList)
        
        self.SetBackgroundColour("WHITE")
        CLlabel=wx.StaticText(self,-1,"Confercence List:")
        self.CListbox=wx.ListBox(self,-1,choices=self.CList)
        self.Bind(wx.EVT_LISTBOX, self.Selected,self.CListbox)
        self.b1=wx.Button(self,-1,'build new conference')
        self.Bind(wx.EVT_BUTTON,self.BnewC,self.b1)
        self.b2=wx.Button(self,-1,'join selected conference')
        self.b2.Disable()
        self.Bind(wx.EVT_BUTTON,self.JoinC,self.b2)
        self.b4=wx.Button(self,-1,'update conference list')
        self.Bind(wx.EVT_BUTTON,self.UpdateClist,self.b4)
        self.b3=wx.Button(self,-1,'Quit')
        self.Bind(wx.EVT_BUTTON,self.Close,self.b3)
        
        mbox=wx.BoxSizer(wx.HORIZONTAL)
        v1box=wx.BoxSizer(wx.VERTICAL)
        v1box.AddMany([(CLlabel,0,wx.EXPAND),(self.CListbox,1,wx.EXPAND)])
        vbox=wx.BoxSizer(wx.VERTICAL)
        vbox.AddMany([(self.b1,1,wx.EXPAND),(self.b2,1,wx.EXPAND),(self.b4,1,wx.EXPAND),(self.b3,1,wx.EXPAND)])
        mbox.AddMany([(v1box,1,wx.EXPAND),(vbox,1,wx.EXPAND)])
        self.SetSizer(mbox)
        
    def Selected(self,event):
        self.b2.Enable()
    def GetClist(self):
        #get Conference list by xmlrpc
        #userlist=DHSProxy.Userlist
        #userlist=SkypeProxy.getuserlist()
        #return userlist
        return ['a','b','c','d']
    def UpdateClist(self,event):
        #get Conference list by xmlrpc
        #self.CList=DHSProxy.Userlist
        #self.CList=SkypeProxy.getuserlist()
        #self.CListbox.Set(CList)
        self.CListbox.Set(['a','b'])
        self.b2.Disable()
    def BnewC(self,event):
        BCFrame=GUIBC("build new conference",self)
        BCFrame.Show()
        self.Hide()
    def JoinC(self,event):  
        Cname=self.CList[self.CListbox.GetSelection()]
        #SkypeProxy apply to join in
        #wait...
        #if success
        
        Cframe=VCMain("Skype VC",0,self)#(conference name)
        Cframe.Show()
        self.Hide()
        print Cname
    def Close(self,event):
        self.Destroy()
    

class GUIBC(wx.Frame):
    def __init__(self,title,parent=None,id=-1,size=(700,500)):
        wx.Frame.__init__(self,parent,id,title,size)
        self.parent=parent
        self.UList=self.GetUlist()
        print self.UList
        self.MList=[]
        self.selections=[]
        self.strings=[]
        self.selections=[]
        self.lst = [ 'a','b','c','d' ]
        
        
        self.SetBackgroundColour("WHITE")
        ULlabel=wx.StaticText(self,-1,"All User List:")
        self.UListbox=wx.ListBox(self,-1,choices=self.UList)
        self.Bind(wx.EVT_LISTBOX, self.USelected, self.UListbox)
        MLlabel=wx.StaticText(self,-1,"Users You Want to \nJoin The Conference:")
        self.MListbox=wx.ListBox(self,-1,choices=[])
        self.Bind(wx.EVT_LISTBOX, self.Mselected, self.MListbox)
        self.b3=wx.Button(self,-1,'>>')
        self.b3.Disable()
        self.Bind(wx.EVT_BUTTON, self.Add,self.b3)
        self.b4=wx.Button(self,-1,'<<')
        self.b4.Disable()
        self.Bind(wx.EVT_BUTTON, self.Del,self.b4)
        self.b1=wx.Button(self,-1,'build')
        self.Bind(wx.EVT_BUTTON,self.BuildC,self.b1)
        self.b5=wx.Button(self,-1,'update')
        self.Bind(wx.EVT_BUTTON, self.UpdateUlist, self.b5)
        self.b6=wx.Button(self,-1,'config')
        self.Bind(wx.EVT_BUTTON, self.Config, self.b6)
        self.b7=wx.Button(self,-1,'OK')
        self.Bind(wx.EVT_BUTTON, self.ok, self.b7)
        self.b2=wx.Button(self,-1,'Cancel')
        self.Bind(wx.EVT_BUTTON,self.Close,self.b2)
        #layout
        mbox=wx.BoxSizer(wx.HORIZONTAL)
        v2box=wx.BoxSizer(wx.VERTICAL)
        v2box.AddMany([(ULlabel,0,wx.EXPAND),(self.UListbox,1,wx.EXPAND)])
        v1box=wx.BoxSizer(wx.VERTICAL)
        v1box.AddMany([(self.b3,0,wx.CENTER),(self.b4,0,wx.CENTER)])
        v3box=wx.BoxSizer(wx.VERTICAL)
        v3box.AddMany([(MLlabel,0,wx.EXPAND),(self.MListbox,1,wx.EXPAND)])
        vbox=wx.BoxSizer(wx.VERTICAL)
        vbox.AddMany([(self.b1,1,wx.CENTER),(self.b5,1,wx.CENTER),(self.b6,1,wx.CENTER),(self.b7,1,wx.CENTER),(self.b2,1,wx.CENTER)])
        mbox.AddMany([(v2box,3,wx.EXPAND|wx.ALL,5),(v1box,1,wx.CENTER|wx.ALL,5),(v3box,3,wx.EXPAND|wx.ALL,5),(vbox,2,wx.BOTTOM|wx.ALL,5)])
        self.SetSizer(mbox)
        
    def Add(self,event):
        self.MList.append(self.UList[self.UListbox.GetSelection()]) 
        self.MListbox.Set(self.MList)
        self.UList.pop(self.UListbox.GetSelection())
        self.UListbox.Set(self.UList)
    def Del(self,event):
        self.UList.append(self.MList[self.MListbox.GetSelection()])
        self.UListbox.Set(self.UList)
        self.MList.pop(self.MListbox.GetSelection())
        self.MListbox.Set(self.MList)
    def USelected(self,event):
        self.b3.Enable()
        self.b4.Disable()
    def Mselected(self,event):
        self.b4.Enable()
        self.b3.Disable()
    def UpdateUlist(self,event):
        #get User list by xmlrpc
        self.UList=['a','b']
        toremove1=[]
        toremove2=[]
        for mem in self.MList:
            flag=0
            for user in self.UList:
                if mem==user:
                    toremove1.append(user)
                    flag=1
            if flag==0:
                toremove2.append(mem)
        for item in toremove1:
            self.UList.remove(item)
        for item in toremove2:
            self.MList.remove(item)
        self.UListbox.Set(self.UList)
        self.MListbox.Set(self.MList)
        self.b3.Disable()
        self.b4.Disable()
    def Config(self,event):
        dlg = wx.MultiChoiceDialog( self,"please select the authority for all member","Conference set", self.lst)
        dlg.SetSelections(self.selections)
        if (dlg.ShowModal() == wx.ID_OK):
            self.selections = dlg.GetSelections()
            self.strings = [self.lst[x] for x in self.selections]
        dlg.Destroy()
    def GetUlist(self):
        #get User list by xmlrpc
        return ['a','b','c','d','e']
    def BuildC(self,event):
        #SkypeProxy.BC(self.MList)
        if self.MList!=[]:
            self.Hide()
            self.frame=VCMain('SKYVC',1,self)
            self.frame.Show()
            print "build new conference"
        else:
            print "please add at least one member"
    def ok(self,event):
        self.Hide()
        self.frame.memberlist.Set(self.MList)
    def Close(self,event):
        self.Destroy()
        self.parent.Show()
        
        
class PenStyleComboBox(wx.combo.OwnerDrawnComboBox):
    def OnDrawItem(self, dc, rect, item, flags):
        if item == wx.NOT_FOUND:
            return

        r = wx.Rect(*rect)  # make a copy
        r.Deflate(3, 5)

        penStyle = wx.SOLID
        if item == 1:
            penStyle = wx.TRANSPARENT
        elif item == 2:
            penStyle = wx.DOT
        elif item == 3:
            penStyle = wx.LONG_DASH
        elif item == 4:
            penStyle = wx.SHORT_DASH
        elif item == 5:
            penStyle = wx.DOT_DASH
        elif item == 6:
            penStyle = wx.BDIAGONAL_HATCH
        elif item == 7:
            penStyle = wx.CROSSDIAG_HATCH
        elif item == 8:
            penStyle = wx.FDIAGONAL_HATCH
        elif item == 9:
            penStyle = wx.CROSS_HATCH
        elif item == 10:
            penStyle = wx.HORIZONTAL_HATCH
        elif item == 11:
            penStyle = wx.VERTICAL_HATCH
            
        pen = wx.Pen(dc.GetTextForeground(), 3, penStyle)
        dc.SetPen(pen)

        if flags & wx.combo.ODCB_PAINTING_CONTROL:
           # for painting the control itself
           dc.DrawLine( r.x+5, r.y+r.height/2, r.x+r.width - 5, r.y+r.height/2 )

        else:
            # for painting the items in the popup
            dc.DrawText(self.GetString( item ),
                        r.x + 3,
                        (r.y + 0) + ( (r.height/2) - dc.GetCharHeight() )/2
                        )
            dc.DrawLine( r.x+5, r.y+((r.height/4)*3)+1, r.x+r.width - 5, r.y+((r.height/4)*3)+1 )
            return penStyle
        
    def OnDrawBackground(self, dc, rect, item, flags):
        # If the item is selected, or its item # iseven, or we are painting the
        # combo control itself, then use the default rendering.
        if (item & 1 == 0 or flags & (wx.combo.ODCB_PAINTING_CONTROL |
                                      wx.combo.ODCB_PAINTING_SELECTED)):
            wx.combo.OwnerDrawnComboBox.OnDrawBackground(self, dc, rect, item, flags)
            return

        # Otherwise, draw every other background with different colour.
        bgCol = wx.Colour(240,240,250)
        dc.SetBrush(wx.Brush(bgCol))
        dc.SetPen(wx.Pen(bgCol))
        dc.DrawRectangleRect(rect);



    # Overridden from OwnerDrawnComboBox, should return the height
    # needed to display an item in the popup, or -1 for default
    def OnMeasureItem(self, item):
        # Simply demonstrate the ability to have variable-height items
        if item & 1:
            return 36
        else:
            return 24

    # Overridden from OwnerDrawnComboBox.  Callback for item width, or
    # -1 for default/undetermined
    def OnMeasureItemWidth(self, item):
        return -1; # default - will be measured from text width

class Line(ogl.DrawnShape):
    def __init__(self,l):
        ogl.DrawnShape.__init__(self)
        self.SetHeight(5)
        self.DrawLine((-l,0 ), (l, 0))

        
class MyEvtHandler(ogl.ShapeEvtHandler):
    def __init__(self, frame):
        ogl.ShapeEvtHandler.__init__(self)
        #self.log = log
        self.statbarFrame = frame
        

    def UpdateStatusBar(self, shape):
        x, y = shape.GetX(), shape.GetY()
        width, height = shape.GetBoundingBoxMax()
        self.statbarFrame.SetStatusText("Pos: (%d, %d)  Size: (%d, %d)" %(x, y, width, height))


    def OnLeftClick(self, x, y, keys=0, attachment=0):
        shape = self.GetShape()
        canvas = shape.GetCanvas()
        dc = wx.ClientDC(canvas)
        canvas.PrepareDC(dc)
        if canvas.editCondtion==0:
            if shape.Selected():
                shape.Select(False, dc)
                canvas.Refresh(False)
            else:
                redraw = False
                shapeList = canvas.GetDiagram().GetShapeList()
                toUnselect = []
    
                for s in shapeList:
                    if s.Selected():
                        toUnselect.append(s)
    
                shape.Select(True, dc)
    
                if toUnselect:
                    for s in toUnselect:
                        s.Select(False, dc)
    
                    canvas.Refresh(False)
    
            self.UpdateStatusBar(shape)
        else:
            print "shape delete"
            shape.Erase(dc)
            shape.Delete()
            canvas.Redraw(dc)

    def OnEndDragLeft(self, x, y, keys=0, attachment=0):
        shape = self.GetShape()
        ogl.ShapeEvtHandler.OnEndDragLeft(self, x, y, keys, attachment)

        if not shape.Selected():
            self.OnLeftClick(x, y, keys, attachment)

        self.UpdateStatusBar(shape)

    def OnSizingEndDragLeft(self, pt, x, y, keys, attch):
        ogl.ShapeEvtHandler.OnSizingEndDragLeft(self, pt, x, y, keys, attch)
        self.UpdateStatusBar(self.GetShape())


    def OnMovePost(self, dc, x, y, oldX, oldY, display):
        shape = self.GetShape()
        ogl.ShapeEvtHandler.OnMovePost(self, dc, x, y, oldX, oldY, display)
        self.UpdateStatusBar(shape)
        if "wxMac" in wx.PlatformInfo:
            shape.GetCanvas().Refresh(False)

    def OnRightClick(self, x, y, keys=0, attachment=0):
        shape = self.GetShape()
        canvas = shape.GetCanvas()  
        canvas.PopupMenuXY(canvas.menu,x,y)
        canvas.shapeselect.append(shape)
    
          
class DrawPanel(ogl.ShapeCanvas):
    def __init__(self, parent, frame):
        ogl.ShapeCanvas.__init__(self, parent)

        self.frame = frame
        self.SetBackgroundColour("LIGHT BLUE")
        self.diagram = ogl.Diagram()
        self.SetDiagram(self.diagram)
        self.diagram.SetCanvas(self)
        self.shapes = []
        self.save_gdi = []
        
        self.graphType = 0
        self.pencolor = "BLACK"
        self.brushcolor = "WHITE"
        self.editCondtion = 0
        self.graphtext = ""
        self.shapeselect=[]
        
        self.menu=wx.Menu()
        for text in ["edit text","delete"]:
            item = self.menu.Append(-1, text)
            self.Bind(wx.EVT_MENU, self.OnPopupItemSelected, item)
        
    def MyAddShape(self, shape, x, y, pen, brush, text):
        # Composites have to be moved for all children to get in place
        print ".....in MyAddShape"
        if isinstance(shape, ogl.CompositeShape):
            dc = wx.ClientDC(self)
            self.PrepareDC(dc)
            shape.Move(dc, x, y)
        else:
            shape.SetDraggable(True, True)
        shape.SetCanvas(self)
        shape.SetX(x)
        shape.SetY(y)
        if pen:    shape.SetPen(pen)
        if brush:  shape.SetBrush(brush)
        if text:
            for line in text.split('\n'):
                shape.AddText(line)
        #shape.SetShadowMode(ogl.SHADOW_RIGHT)
        self.diagram.AddShape(shape)
        shape.Show(True)
        
        self.shapes.append(shape)
        #print self.shapes
        return shape 
      
    def OnLeftClick(self, x,y,key):
        if self.editCondtion==0:
            print "Left Clcik is called"
            item=self.frame.pscb.GetSelection()
            penStyle = wx.SOLID
            if item == 1:
                penStyle = wx.TRANSPARENT
            elif item == 2:
                penStyle = wx.DOT
            elif item == 3:
                penStyle = wx.LONG_DASH
            elif item == 4:
                penStyle = wx.SHORT_DASH
            elif item == 5:
                penStyle = wx.DOT_DASH
            elif item == 6:
                penStyle = wx.BDIAGONAL_HATCH
            elif item == 7:
                penStyle = wx.CROSSDIAG_HATCH
            elif item == 8:
                penStyle = wx.FDIAGONAL_HATCH
            elif item == 9:
                penStyle = wx.CROSS_HATCH
            elif item == 10:
                penStyle = wx.HORIZONTAL_HATCH
            elif item == 11:
                penStyle = wx.VERTICAL_HATCH          
            self.pensize=self.frame.pensize.GetValue()
            print self.pensize
            if self.graphType==0:
                shape=self.MyAddShape(ogl.EllipseShape(60,80), x, y, wx.Pen(self.pencolor,self.pensize,penStyle), wx.Brush(self.brushcolor), self.graphtext)          
            elif self.graphType==1:
                shape=self.MyAddShape(ogl.RectangleShape(60,80), x, y, wx.Pen(self.pencolor,self.pensize,penStyle), wx.Brush(self.brushcolor), self.graphtext)
            elif self.graphType==2:
                shape=self.MyAddShape(ogl.TextShape(120, 45), x, y, wx.Pen(self.pencolor,self.pensize,penStyle), wx.Brush(self.brushcolor), self.graphtext)
            elif self.graphType==3:
                shape=self.MyAddShape(Line(40), x, y, wx.Pen(self.pencolor,self.pensize,penStyle),wx.Brush(self.brushcolor), self.graphtext)
            self.evthandler = MyEvtHandler(self.frame)
            self.evthandler.SetShape(shape)
            self.evthandler.SetPreviousHandler(shape.GetEventHandler())
            shape.SetEventHandler(self.evthandler)
            dc = wx.ClientDC(self)
            self.Redraw(dc)
    def OnPopupItemSelected(self,event):
        item = self.menu.FindItemById(event.GetId())
        text=item.GetText()
        pos=self.GetPosition()
        if (text == "edit text"):
            dlg = wx.TextEntryDialog(self, 'Please entry text:','TextEntryDialog', '')
            if dlg.ShowModal() == wx.ID_OK:
                self.graphtext=dlg.GetValue()
            self.shapeselect[0]
        elif(text=="delete"):
            print self.shapeselect[0]
            self.shapeselect[0].Delete()
    
        
class VCMain(wx.Frame):
    def __init__(self,title,type,parent=None,id=-1):
        wx.Frame.__init__(self,parent,id,title,size=(700,500))
        self.parent=parent
        self.type=type #1:host
        self.page=1
        #self.panel=wx.Panel(self,-1)
        
        menubar = wx.MenuBar() 
        file = wx.Menu()
        MenuItem1=file.Append(-1,"add page")
        edit = wx.Menu() 
        help = wx.Menu() 
        menubar.Append(file, "&File") 
        menubar.Append(edit, "&edit") 
        menubar.Append(help, "&help") 
        self.SetMenuBar(menubar)
        
        self.Bind(wx.EVT_MENU, self.AddPage,MenuItem1)
        
        self.canvas=DrawPanel(self,self)
        self.nb = wx.aui.AuiNotebook(self)
        self.nb.AddPage(self.canvas, str(self.page))
        self.message=wx.TextCtrl(self,-1,"",style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER)
        self.message1=wx.TextCtrl(self,-1,"",style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER)
        b1=wx.Button(self,-1,"send")
        self.Bind(wx.EVT_BUTTON, self.MsgSend,b1)
        b2=wx.Button(self,-1,"clear")
        self.Bind(wx.EVT_BUTTON, self.MsgClear,b2)
        pencolortxt=wx.StaticText(self, -1, "Pen Color:",style=wx.ALIGN_CENTER)
        #pencolortxt.SetBackgroundColour("white")
        pencolor=csel.ColourSelect(self,-1,"",(0,0,0),size=wx.DefaultSize)
        self.Bind(csel.EVT_COLOURSELECT, self.OnPenColorSelect, pencolor)
        fillcolortxt=wx.StaticText(self,-1,"Fill Color:",style=wx.ALIGN_CENTER)
        #fillcolortxt.SetBackgroundColour("white")
        fillcolor=csel.ColourSelect(self,-1,"",(255,255,255),size=wx.DefaultSize)
        self.Bind(csel.EVT_COLOURSELECT, self.OnFillColorSelect, fillcolor)
        penstyletxt=wx.StaticText(self, -1, "Pen Styles:",style=wx.ALIGN_CENTER)
        self.penStyles = ["wx.Solid","wx.Transparent","wx.Dot","wx.Long Dash","Short Dash","Dot Dash","Backward Diagonal Hatch","Cross-diagonal Hatch","Forward Diagonal Hatch","Cross Hatch","Horizontal Hatch","Vertical Hatch"]
        self.pscb = PenStyleComboBox(self, choices=self.penStyles, style=wx.CB_READONLY,pos=(20,40), size=(250, -1))
        pensizetxt=wx.StaticText(self,-1,"Pen Size:",style=wx.ALIGN_CENTER)
        self.pensize=wx.SpinCtrl(self, -1, "2", (30, 50))
        self.pensize.SetRange(1,10)
        #sc.SetValue(5)
        shlistlabel=wx.StaticText(self,-1,"DrawType:",style=wx.DEFAULT)
        self.ShapeList=["Ellipse","Rectangle","Text","horizontal line"]
        self.shapetype=wx.Choice(self,-1, choices = self.ShapeList,style=2)
        self.shapetype.SetSelection(0)
        self.Bind(wx.EVT_CHOICE, self.ShapeChoice, self.shapetype)
        shtxtlabel=wx.StaticText(self,-1,"Text in Graph:",style=wx.DEFAULT)
        self.shapetxt=wx.TextCtrl(self,-1,"")
        self.Bind(wx.EVT_TEXT, self.txtchange, self.shapetxt)
        self.checkdel=wx.CheckBox(self,-1,"Delete")
        self.Bind(wx.EVT_CHECKBOX, self.EvtCheckDel, self.checkdel)
        self.memberlist=wx.ListBox(self,-1,(5,5),(130,130),self.parent.MList,wx.SIMPLE_BORDER)
        self.Bind(wx.EVT_LISTBOX, self.MemberSelect, self.memberlist)
        if self.type==1:
            self.buadd=wx.Button(self,-1,"add")
            self.Bind(wx.EVT_BUTTON, self.AddMember, self.buadd)
            self.budelete=wx.Button(self,-1,"del")
            self.budelete.Disable()
            self.Bind(wx.EVT_BUTTON, self.DelMember, self.budelete)
            self.bumute=wx.Button(self,-1,"mute")
            self.bumute.Disable()
            self.Bind(wx.EVT_BUTTON, self.Mute, self.bumute)
            self.bucfg=wx.Button(self,-1,"Config")
            self.Bind(wx.EVT_BUTTON, self.Config, self.bucfg)
        
        self.buout=wx.Button(self,-1,"Quit")
        self.Bind(wx.EVT_BUTTON, self.Close,self.buout)
        self.CreateStatusBar()
        frame1=GUIBC("a")
        
        #interface
        mbox=wx.BoxSizer(wx.HORIZONTAL)
        lbox=wx.BoxSizer(wx.VERTICAL)
        l1box=wx.BoxSizer(wx.HORIZONTAL)
        l1box.AddMany([(b1,1,wx.EXPAND),(b2,1,wx.EXPAND)])
        lbox.AddMany([(self.nb,8,wx.EXPAND),(self.message,2,wx.EXPAND),(self.message1,1,wx.EXPAND),(l1box,0,wx.EXPAND)])
        rbox=wx.BoxSizer(wx.VERTICAL)
        r1box=wx.BoxSizer(wx.HORIZONTAL)
        r1box.AddMany([(pencolortxt,1,wx.EXPAND),(pencolor,1,wx.ALIGN_CENTER)])
        r2box=wx.BoxSizer(wx.HORIZONTAL)
        r2box.AddMany([(fillcolortxt,1,wx.EXPAND),(fillcolor,1,wx.ALIGN_CENTER)])
        r3box=wx.BoxSizer(wx.HORIZONTAL)
        r3box.AddMany([(penstyletxt,1,wx.EXPAND),(self.pscb,1,wx.EXPAND)])
        r4box=wx.BoxSizer(wx.HORIZONTAL)
        r4box.AddMany([(pensizetxt,1,wx.EXPAND),(self.pensize,1,wx.EXPAND)])
        r6box=wx.BoxSizer(wx.HORIZONTAL)
        r6box.AddMany([(shlistlabel,1,wx.EXPAND),(self.shapetype,1,wx.EXPAND)])
        r7box=wx.BoxSizer(wx.HORIZONTAL)
        r7box.AddMany([(shtxtlabel,1,wx.EXPAND),(self.shapetxt,1,wx.EXPAND)])
        if self.type==1:
            r5box=wx.BoxSizer(wx.HORIZONTAL)
            r5box.AddMany([(self.buadd,1,wx.EXPAND),(self.budelete,1,wx.EXPAND),(self.bumute,1,wx.EXPAND)])
            rbox.AddMany([(r1box,0,wx.EXPAND),(r2box,0,wx.EXPAND),(r3box,0,wx.EXPAND),(r4box,0,wx.EXPAND),(r6box,0,wx.EXPAND),(r7box,0,wx.EXPAND),(self.checkdel,0,wx.EXPAND),(self.memberlist,1,wx.EXPAND),(r5box,0,wx.EXPAND),(self.bucfg,0,wx.EXPAND),(self.buout,0,wx.EXPAND)])
        else:
            rbox.AddMany([(r1box,0,wx.EXPAND),(r2box,0,wx.EXPAND),(r3box,0,wx.EXPAND),(r4box,0,wx.EXPAND),(r6box,0,wx.EXPAND),(r7box,0,wx.EXPAND),(self.checkdel,0,wx.EXPAND),(self.memberlist,1,wx.EXPAND),(self.buout,0,wx.EXPAND)])
        mbox.AddMany([(lbox,3,wx.EXPAND|wx.ALL,5),(rbox,1,wx.EXPAND|wx.ALL,5)])
        self.SetSizer(mbox)
    def AddPage(self,event):
        self.page=self.page+1
        canvas=DrawPanel(self,self)
        self.nb.AddPage(canvas,str(self.page))
    def MsgSend(self,event):
        text=self.message1.GetLabelText()
        self.message.AppendText("me:"+text)
        #send message
    def MsgClear(self,event):
        self.message.Clear()
    def OnPenColorSelect(self,event):     
        for canvas in self.nb.GetChildren():
            canvas.pencolor=event.GetValue()
    def OnChangeStyle(self,event):
        print event.GetValue()
    def OnFillColorSelect(self,event):
        for canvas in self.nb.GetChildren():
            canvas.brushcolor=event.GetValue()
    def ShapeChoice(self,event):
        for canvas in self.nb.GetChildren():
            canvas.graphType=self.shapetype.GetSelection()
    def txtchange(self,event):
        for canvas in self.nb.GetChildren():
            canvas.graphtext=event.GetString()
    def EvtCheckDel(self,event):
        for canvas in self.nb.GetChildren():
            canvas.editCondtion=event.IsChecked()
    def MemberSelect(self,event):
        self.budelete.Enable()
        self.bumute.Enable()
    def AddMember(self,event):
        self.parent.Show()
        self.parent.UListbox.Set(self.parent.UList)
        self.parent.MListbox.Set(self.parent.MList)
    def DelMember(self,event):
        #skypeservice
        print "Delete selected Member"
        self.parent.UList.append(self.parent.MList[self.memberlist.GetSelection()])
        self.parent.MList.remove(self.parent.MList[self.memberlist.GetSelection()])
        self.memberlist.Set(self.parent.MList)
    def Mute(self,event):
        #skypeservice
        print "Mute selected Member"
        
    def Config(self,event):
        dlg = wx.MultiChoiceDialog( self,"please select the authority for all member","Conference set", self.parent.lst)
        dlg.SetSelections(self.parent.selections)
        if (dlg.ShowModal() == wx.ID_OK):
            self.parent.selections = dlg.GetSelections()
            self.parent.strings = [self.parent.lst[x] for x in self.parent.selections]
        dlg.Destroy()
        
    def Close(self,event):
        if self.type==0:
            self.Destroy()
            self.parent.Show()
        elif self.type==1:
            self.parent.parent.Show()
            self.parent.Destroy()
            self.Destroy()
            
            
def main():
    app=wx.PySimpleApp()
    frame=GUISetup('Welcome to SKYVC')
    #frame=GUIBC('build new conference')
    #frame=VCMain("SKYVC")
    frame.Show()
    ogl.OGLInitialize()
    #Csetting=settings([],[])
    app.MainLoop()

if __name__=="__main__":
    main()